﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using TuyenSinh.Ultilities;

namespace TuyenSinh.DLL
{
    public class DUser : BaseDAL
    {
        public bool LoginAdmin(string sUser, string sPassword, int roleId)
        {
            bool bResult = false;
            try
            {
                DbCommand cmd = DB.GetStoredProcCommand("AdminLogin");// aGetUserInfo  aGetAccInfoByUserID
                DB.AddInParameter(cmd, "@Username", SqlDbType.VarChar, sUser); //iwUserId 
                DB.AddInParameter(cmd, "@Password", SqlDbType.NChar, sPassword); //iwUserId 

                DB.AddInParameter(cmd, "@Role", SqlDbType.Bit, roleId == 1);

                DataSet ds = DB.ExecuteDataSet(cmd);
                bResult = ds.Tables[0].Rows.Count != 0;

            }
            catch (Exception ex)
            {
                Logger.FrameworkLogger.Error("Login ", ex);
                bResult = false;
            }

            return bResult;
        }
    }
}
